#ifndef __MOTOR_H
#define __MOTOR_H

#include 	"stdint.h"

#define MOTOR_FUNC_READ_REG                 0X03
#define MOTOR_FUNC_READ_REG_ERROR           0X83
#define MOTOR_FUNC_WRITE_SINGLE_REG         0X06
#define MOTOR_FUNC_WRITE__REG_ERROR         0X86
#define MOTOR_FUNC_WIRTE_MULTIPLE_REG       0X10


#define MOTOR_QUERY_REALTIME_PWM           0X0020
#define MOTOR_CTL_STOP_REG                 0X0040
#define MOTOR_CTL_SET_DUTY_CYCLE_REG       0X0043

extern uint8_t MotorCtlBuffer[8];
extern uint8_t g_ucMotorCtlStep;
extern uint8_t g_ucMotorCtlFlag;
extern int32_t g_iMoto1BiasData;
extern int32_t g_iMoto2BiasData;
extern int32_t g_iMotor1BiasData;
extern int32_t g_iMotor2BiasData;
extern uint8_t g_ucMotorSendDataReady;
extern uint8_t g_ucMotorSendDataCount;
extern float  g_ucMotor1;
extern float  g_ucMotor2;
extern float  g_ucMotor3;






double rpmToValue(double rpm);
double linearToRpm(double lin);

void USART1_Motor_Query(void);
void USART1_Motor_Broadcast(uint8_t ucCMD, uint16_t ucAddr, uint16_t MotorData);
void USART1_Motor_Stop(void);
void USART1_Send_Data(uint8_t ucCMD, uint16_t ucAddr, uint16_t Motor1Speed, uint16_t Motor2Speed);
void MotorAckAnaly(void);
//void USART1_Wifi_Send(void);
void USART1_SendByte(unsigned char temp);
void USART1_Write(uint8_t	*pu8TxBuf, 	uint32_t u32WriteBytes);


#endif /* __MAIN_H */
